home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1999 March
/
EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso
/
earcd
/
-archivi
/
-recent2
/
amhelios.lha
/
AmHelios
/
hemicube.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1997-07-13
|
3KB
|
114 lines
////////////////////////////////////////////////////////////
//
// HEMICUBE.CPP - Hemicube Class
//
// Version: 1.03A
//
// History: 94/08/23 - Version 1.00A release.
// 94/12/16 - Version 1.01A release.
// 95/02/05 - Version 1.02A release.
// 95/07/21 - Version 1.02B release.
// 96/02/14 - Version 1.02C release.
// 96/04/01 - Version 1.03A release.
//
// Compilers: Microsoft Visual C/C++ Professional V1.5
// Borland C++ Version 4.5
//
// Author: Ian Ashdown, P.Eng.
// byHeart Software Limited
// 620 Ballantree Road
// West Vancouver, B.C.
// Canada V7S 1W3
// Tel. (604) 922-6148
// Fax. (604) 987-7621
//
// Copyright 1994-1996 byHeart Software Limited
//
// The following source code has been derived from:
//
// Ashdown, I. 1994. Radiosity: A Programmer's
// Perspective. New York, NY: John Wiley & Sons.
//
// It may be freely copied, redistributed, and/or modified
// for personal use ONLY, as long as the copyright notice
// is included with all source code files.
//
////////////////////////////////////////////////////////////
#include "hemicube.h"
void HemiCube::CalcFormFactors( Patch3 *pp, Instance *pi,
float *ff_array, WORD num_elem )
{
int i; // Loop index
BOOL hidden; // Patch visibility flag
BOOL self; // Self patch flag
WORD j; // Loop index
WORD elem_id; // Element identifier
Element3 *pelem; // Element pointer
Instance *pinst; // Instance pointer
Patch3 *ppatch; // Patch pointer
Surface3 *psurf; // Surface pointer
// Clear the form factors array
for (j = 0; j < num_elem; j++)
ff_array[j] = 0.0;
// Set the hemicube view transformation matrix
clip.SetView(pp);
// Project environment onto each hemicube face
for (i = 0; i < HemiFaceNum; i++)
{
// Update view transformation matrix
clip.UpdateView(i);
scan.InitBuffer(); // Reinitialize depth buffer
// Walk the instance list
elem_id = 1;
pinst = pi;
while (pinst != NULL)
{
// Walk the surface list
psurf = pinst->GetSurfPtr();
while (psurf != NULL)
{
// Walk the patch list
ppatch = psurf->GetPatchPtr();
while (ppatch != NULL)
{
// Check for self patch
self = (ppatch == pp) ? TRUE : FALSE;
// Determine patch visibility
hidden = clip.BackFaceCull(ppatch);
// Walk the element list
pelem = ppatch->GetElementPtr();
while (pelem != NULL)
{
if (hidden == FALSE && self == FALSE)
{
// Clip element to face view volume
if (clip.Clip(pelem, out, elem_id) > 0)
{
scan.Scan(out); // Scan convert polygon
}
}
pelem = pelem->GetNext();
elem_id++;
}
ppatch = ppatch->GetNext();
}
psurf = psurf->GetNext();
}
pinst = pinst->GetNext();
}
// Sum delta form factors
scan.SumDeltas(ff_array, i);
}
}